package com.dxc.intern.service.impl;

import com.dxc.intern.entity.Page;
import com.dxc.intern.entity.QrCode;
import com.dxc.intern.mapper.QrCodeMapper;
import com.dxc.intern.service.QrCodeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 二维码(求职者扫码操作) 服务实现类
 * </p>
 *
 * @author zhangchengming
 * @since 2022-02-21
 */
@Service
public class QrCodeServiceImpl extends ServiceImpl<QrCodeMapper, QrCode> implements QrCodeService {

    @Autowired
    private QrCodeMapper qrCodeMapper;


    @Override
    public Page<QrCode> page(Integer pageNo, Integer pageSize) {
        int total =qrCodeMapper.count();
        int index= pageNo == 1 ? 0 : (pageNo - 1) * pageSize;
        List<QrCode> qrCodes=qrCodeMapper.page(index,pageSize);
        return new Page<QrCode>(pageSize,pageNo,total,qrCodes);
    }
    @Override
    public Page<QrCode> selectLike(Integer pageNo, Integer pageSize,QrCode qrCode) {
        int total =qrCodeMapper.count();
        int index= pageNo == 1 ? 0 : (pageNo - 1) * pageSize;
        List<QrCode> qrCodes=qrCodeMapper.selectLike(index,pageSize,qrCode);
        return new Page<QrCode>(pageSize,pageNo,total,qrCodes);
    }

    @Override
    public boolean insert(QrCode qrCode) {
        int i= qrCodeMapper.insert(qrCode);
        return i>0;
    }

    @Override
    public boolean delete(Integer id) {
        int i=qrCodeMapper.delete(id);
        return i>0;
    }


    @Override
    public boolean update(QrCode qrCode) {
        int i=qrCodeMapper.update(qrCode);
        return i>0;
    }


}
